<template>
  <div>
    <el-radio-group v-if="!disabled" :value="value">
      <el-radio v-for="(item, index) in options" :key="index" :label="item.label">{{ item.name }}</el-radio>
    </el-radio-group>
    <div v-else>{{ valText }}</div>
  </div>
</template>
<script>
export default {
  props: {
    value: [String, Number],
    options: {
      type: Array,
      default: () => []
    },
    disabled: {
      type: Boolean,
      default: () => false
    },
    placeholder: {
      type: String,
      default: ''
    },
    clearable: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: 'small'
    }
  },
  data() {
    return {
      valText: ''
    }
  },
  watch: {
    value: {
      handler(val) {
        if (val) {
          this.valText = this.options.find(it => it.label == val)?.name
        } else {
          // this.fileList = []
          // this.imageList = []
          this.valText = ''
          return []
        }
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    input(e) {
      this.$emit('input', e.target.value)
    }
  }
}
</script>
